package com.xxx.video.dynamic.presenters;

import android.content.Context;

import androidx.annotation.NonNull;

import com.xxx.video.commen.beans.BaseBean;
import com.xxx.video.commen.presenters.BasePresenter;
import com.xxx.video.commen.utils.ResponseUtils;
import com.xxx.video.dynamic.beans.ReceiverFriendListBean;
import com.xxx.video.network.listeners.CommonResponseListener;
import com.xxx.video.network.utils.NetWorkUtils;

public class MyGetFriendRequestPresenter extends BasePresenter<IMyGetFriendRequestView> {

    public MyGetFriendRequestPresenter(@NonNull Context context, IMyGetFriendRequestView baseView) {
        super(context, baseView);
    }

    /**
     * get receiver friend list
     */
    public void getReceivedFriendsList() {
        NetWorkUtils.getInstance().getReceivedFriendsList(new CommonResponseListener<ReceiverFriendListBean>() {

            @Override
            public void onSuccess(ReceiverFriendListBean successOb, String result) {
                if (ResponseUtils.getInstance().isNoError(successOb)) {
                    if (getBaseView() != null) {
                        getBaseView().initData2View(successOb.page);
                    }
                }
            }

            @Override
            public void onFailure(Object failureObj) {
                if (getBaseView() != null) {
                    getBaseView().showRootLayoutStatus(3);
                }
            }
        });
    }

    /**
     * un agree
     *
     * @param fUserId id
     */
    public void refuse(String fUserId) {
        NetWorkUtils.getInstance().refuse(fUserId, new CommonResponseListener<BaseBean>() {
            @Override
            public void onSuccess(BaseBean successOb, String result) {
                if (ResponseUtils.getInstance().isNoError(successOb)) {
                    if (getBaseView() != null) {
                        getBaseView().unAgreeSuccess();
                    }
                }
            }

            @Override
            public void onFailure(Object failureObj) {

            }
        });
    }

    /**
     * agree
     *
     * @param fUserId id
     */
    public void acceptFriends(String fUserId) {
        NetWorkUtils.getInstance().acceptFriends(fUserId, new CommonResponseListener<BaseBean>() {

            @Override
            public void onSuccess(BaseBean successOb, String result) {
                if (ResponseUtils.getInstance().isNoError(successOb)) {
                    if (getBaseView() != null) {
                        getBaseView().acceptFriendsSuccess();
                    }
                }
            }

            @Override
            public void onFailure(Object failureObj) {

            }
        });
    }
}
